﻿@using Aspire.Dashboard.Components.Controls.Grid
@using Aspire.Dashboard.Resources
@typeparam TItem
@inject IStringLocalizer<ControlsStrings> Loc

<FluentDataGrid ResizeLabel="@AspireFluentDataGridHeaderCell.GetResizeLabel(Loc)"
                ResizeType="DataGridResizeType.Discrete"
                Items="@Items"
                ResizableColumns="true"
                Style="width:100%"
                GenerateHeader="@GenerateHeader"
                GridTemplateColumns="@GridTemplateColumns"
                ShowHover="true">
    <AspireTemplateColumn Title="@(NameColumnTitle ?? Loc[nameof(ControlsStrings.NameColumnHeader)])" Class="nameColumn" SortBy="@NameSort" Sortable="@IsNameSortable">
        <GridValue
            ValueDescription="@(NameColumnTitle ?? Loc[nameof(ControlsStrings.NameColumnHeader)])"
            Value="@NameColumnValue(context)"
            HighlightText="@HighlightText" />
    </AspireTemplateColumn>
    <AspireTemplateColumn Title="@(ValueColumnTitle ?? Loc[nameof(ControlsStrings.PropertyGridValueColumnHeader)])" Class="valueColumn" SortBy="@ValueSort" Sortable="@IsValueSortable">
        <GridValue
            ValueDescription="@(ValueColumnTitle ?? Loc[nameof(ControlsStrings.PropertyGridValueColumnHeader)])"
            Value="@ValueColumnValue(context)" HighlightText="@HighlightText"
            EnableMasking="@EnableValueMasking" IsMasked="@GetIsItemMasked(context)"
            IsMaskedChanged="(newValue) => OnIsMaskedChanged(context, newValue)"
            TextVisualizerTitle="@NameColumnValue(context)"/>
        @ExtraValueContent(context)
    </AspireTemplateColumn>
</FluentDataGrid>

